package com.example.day01_weather.mvp.presenter;

import com.example.day01_weather.bean.CityBean;
import com.example.day01_weather.bean.WeatherBean;
import com.example.day01_weather.mvp.model.Model;
import com.example.day01_weather.mvp.view.ICallBack;
import com.example.day01_weather.mvp.view.IWeather;

import java.util.Map;

import javax.security.auth.callback.Callback;

/**
 *
 */
public class Presenter implements IWeather.IPresenter {
    IWeather.IView view;
    IWeather.IModel model;
    public Presenter(IWeather.IView view) {
        this.view = view;
        this.model=new Model();
    }


    @Override
    public void getCityData() {
        this.model.getCityData(new ICallBack() {
            @Override
            public void onSuccess(Object o) {
                view.getCitySuccess((CityBean) o);
            }

            @Override
            public void onError(String error) {
                view.tips(error);
            }
        });
    }

    @Override
    public void getWeatherData(Map<String, String> map) {
        this.model.getWeatherData(map, new ICallBack() {
            @Override
            public void onSuccess(Object o) {
                view.getWeatherSuccess((WeatherBean) o);

            }

            @Override
            public void onError(String error) {
                view.tips(error);
            }
        });
    }
}
